import("System")
import("System.IO.Ports")
import("Jodell.Tool", "Jodell.Tool")
-- 原始站号
BeforeSlaveIDMin = 1
BeforeSlaveIDMax = 12
-- 目标站号
AfterSlaveIDMin = 13
AfterSlaveIDMax = 24
-- 集成设备单爪数
Betch = 12
 
local Lua_ok = 0
local Lua_Error_Notconnect = -1
local Lua_Error_TimeOut = -2
local Lua_Error_DeviceTypeNotEqual = 3
local Lua_Error_change500 = 4
local Lua_Error_Change501 = 5

local versionRegAddr = 558
local saveRegAddr = 1001
local restoreRegAddr = 1002
local caliEncRegAddr = 1004
local searchZeroRegAddr = 1005



local versionCheckBefore = true -- check version before upgrade

client = Lua_ModbusRtuClient()
client.PortName = "COM4"
client:Connect()



for i = 1, 12, 1 do
    upgradeTargetFirmware(client, i)
end

client:Disconnect()
